<#compress>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,  user-scalable=0;" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style"  />
    <meta content="telephone=no" name="format-detection" />
    <link rel="stylesheet" href="${ctx}/static/mobileweb/1/css/common_mc.css?_=${.now?string("yyyy-MM-dd")}">
    <title>会员中心</title>
</head>
<body style="background: #eeeeee;">
<section class="membercenter">
    <div class="vipcard center"><img src="${ctx}/static/mobileweb/1/images/vipcard.png?_=${.now?string('yyyy-MM-dd')}" alt="vipcard" class="wdh100"/></div>
    <div class="memOptionBox">
        <span>NO.${member.card_no!}</span>
        <#if !member.temp>
            <span class="fr">
                <a class='bind' href="${ctx}/mobileweb/member/bindCard?mid=${mid!}&wxno=${wxno!}" id="unbindcard">重新绑定</a>
            </span>
        <#else>
            <span class="fr">
              <a class='bind' href="${ctx}/mobileweb/member/bindCard?mid=${mid!}&wxno=${wxno!}" id="bindcard">绑定会员卡</a>
              <a class="bind" href="${ctx}/mobileweb/member/phone?mid=${mid!}&wxno=${wxno!}">注册会员</a>
           </span>
        </#if>
        <br class="cb"/>
    </div>


    <div class="memberArea">
        <ul class="lists">
            <li><a style="font-size: 100%" href="${ctx}/mobileweb/integral/record?mid=${mid!}&wxno=${wxno!}"><span class="detailquery fr">明细查询</span><i class="dollarico"></i>积分：<span><#if member.temp>0<#else>${member.integral!0}</#if></span>分</a></li>

            <li><a style="font-size: 100%" href="${ctx}/mobileweb/integral/surplus?mid=${mid!}&wxno=${wxno!}"><span class="detailquery fr">规则说明</span><i class="dollarico"></i>预扣积分：<span><#if member.temp>0<#else><#if member.integral?? && member.surplus??>${member.integral - member.surplus}<#else>0</#if></#if></span>分</a></li>
            <li><a style="font-size: 100%" href="${ctx}/mobileweb/member/notice"><i class="addbook"></i>会员须知</a></li>
            <li><a style="font-size: 100%" href="#"><img src="${ctx}/static/mobileweb/1/images/operate.png"/>操作说明</a></li>
        </ul>
    </div>

    <div class="bindcardshow" id="bindcardshow">
        <p class="btns clearfix">
            <span class="fr mr20"><a href="javascript:void(0);" id="submitId">确定</a><a id="cancelId" href="javascript:void(0);" class="ml10 cancelBtn">取消</a></span>
            <span id="message" class="prompt" style="display: none"></span>
        </p>
        <input type="hidden" id="mid" value="${member.id!}">
        <p class="center"><input id="carno" type="tel" class="cardinput" placeholder="会员卡号"/></p>
        <p class="center"><input id="phoneno" type="tel" class="cardinput" placeholder="手机号"/></p>
    </div>
</section>
<script type="text/javascript" src="${ctx}/static/mobileweb/scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
    document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
        WeixinJSBridge.call('hideToolbar');
    });

    $(function(){
//        $('#bindcard,#unbindcard').click(function(){
//            var $box = $('#bindcardshow');
//            if($box.is(':hidden')){
//                $box.slideDown(400);
//            }
//        });

        $('.cancelBtn').click(function(){
            var $message = $("#message");
            $message.css("display","none");
            $message.text("");
            var carno = $("#carno").val("");
            var phoneno = $("#phoneno").val("");
            var $box = $('#bindcardshow');
            if($box.is(':visible')){
                $box.slideUp(400);
            }
        });

        $("#carno,#phoneno").focus(function(){
            var $message = $("#message");
            $message.css("display","none");
            $message.text("");
        });

        $("#submitId").click(function(){
            var carno = $("#carno").val();
            var phoneno = $("#phoneno").val();
            var mid = "${member.id!}";
            var $message = $("#message");
            if(carno == "" || phoneno == ""){
                $message.css("display","block");
                $message.text("请输入会员卡号和手机号！");
                return;
            }

            var regPartton=/1[3-8]+\d{9}/;
            if(!regPartton.test(phoneno)){
                $message.css("display","block");
                $message.text("请输入正确的手机号！");
                return;
            }

            $.post("${ctx}/mobileweb/member/bindCard",{
                mid:mid,
                carno:carno,
                phoneno:phoneno
            },function(data){
                if (data.status == "OK") {
                    location.href="${ctx}/mobileweb/member?mid=${member.id!}&wxno=${wxno!}";
                }else{
                    var $message2 = $("#message");
                    $message2.removeAttr("style");
                    $message2.text(data.message);
                }
            });
        });
    });
    var height = $(document).height(); //浏览器当前窗口文档的高度
    $("body").css("height", height + "px");
</script>
</body>
</html>
</#compress>
